package com.sky.controller.user;

import com.sky.dto.OrdersDTO;
import com.sky.dto.ShoppingCartDTO;
import com.sky.result.Result;
import com.sky.service.ShoppingCartService;
import org.aspectj.lang.annotation.AfterReturning;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user/shoppingCart")
public class ShoppingCartController {
    @Autowired
    ShoppingCartService shoppingCartService;
    @PostMapping("/add")
    public Result add(@RequestBody ShoppingCartDTO shoppingCartDTO){
        return shoppingCartService.add(shoppingCartDTO);
    }

    @GetMapping("/list")
    public Result getByUserId(){
        return shoppingCartService.getByUserId();
    }

    @PostMapping("/sub")
    public Result deleteByDishOrSetmealById(@RequestBody ShoppingCartDTO shoppingCartDTO){
        return shoppingCartService.deleteByDishOrSetmealById(shoppingCartDTO);
    }

    @DeleteMapping("/clean")
    public Result clean(){
        return shoppingCartService.clean();
    }





}
